<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../node_modules/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app"></div>
  <script>
    new Vue({
      template: '<p id="testa">{{num}}</p>',
      data() {
        return {
          num: 100,
          age: 0
        }
      },
      mounted () {
        console.log('mounted', this)
        // 每秒更新num值，会触发beforeUpdate
        setInterval(()=> {
          // this.num++
          this.age++
        },1000)
      },
      beforeUpdate (){
        console.log('beforeUpdate', this) 
      }
    }).$mount('#app')
  </script>
</body>

</html>